using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sharp.Domain.PlatformBoundedContext.WorkFlowModule.Aggregates;

namespace Sharp.Domain.PlatformBoundedContext.ModelConfigurations.Workflow
{
    public partial class TaskEntityConfiguration
        : EntityTypeConfiguration<TaskEntity>
    {
        public TaskEntityConfiguration()
        {
            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                .IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            HasRequired(t => t.ActivityInstance)
                .WithMany(t => t.Tasks).HasForeignKey(t=>t.ActivityInstanceID).WillCascadeOnDelete(false);
            HasRequired(t => t.ProcessInstance)
                .WithMany(t => t.Tasks).HasForeignKey(t => t.ProcessInstanceID);
        }
    }
}